# R Options
options(stringsAsFactors=FALSE)

# Required libraries
library(dplyr)
library(tidyr)
library(ggplot2)
library(patchwork)
library(openxlsx)
library(ggpubr)
library(ggsci)
library(knitr)
library(kableExtra)
library(Seurat)
library(purrr)
library(DT)

# Source plotting functions
source("R/functions_io.R")
source("R/functions_plotting.R")
source("R/functions_analysis.R")
source("R/functions_util.R")

# default options
knitr::opts_chunk$set(echo=TRUE, cache=FALSE, message=FALSE, warning=FALSE, fig.width=10)
options(stringsAsFactors = F)

Dataset description

Read input data

In this first section of the report, we read 10X data from the files produced by CellRanger:

and setup a Seurat object. This object includes different data types in separate assays:

Note that ‘Antibody Capture’ features can correspond to ‘HTO’ and ‘ADT’ and can be distinguised based on provided HTO names.

## An object of class Seurat 
## 21863 features across 2000 samples within 2 assays 
## Active assay: RNA (21855 features)
##  1 other assay present: HTO
Dataset summary
Assay CellsTotal CellsWithHtoReads CellsWithoutHtoReads
RNA 2000 2000 0

Demutliplexing Hashtag Oligos (HTO)

This section of the report shows how cells are assigned to their sample-of-origin.

Normalisation of HTO counts

We start the analysis by normalising raw HTO counts. HTO counts for each cell are divided by the total counts for that cell and multiplied by 10,000. This is then natural-log transformed.

Visualisation of raw and normalised HTO data

This section of the report visualises raw and normalised HTO data to understand whether the demultiplexing step has worked well.

Pairs of raw (left tab) and normalised (right tab) HTO counts are visualised to confirm mutal exclusivity in singlet cells. Data points correspond to measured HTO counts per HTO, colours correspond to the assigned samples-of-origin.

Normalized HTO data

The following ridge plots visualise the enrichment of assigned sample-of-origin for the respective normalised HTO counts.

Lastly, we compare the number of features between classified cells.

Remove cells classified as doublet or negative

This section of the report states the number of cells that remain after negative and doublet cells are removed.

## An object of class Seurat 
## 21863 features across 1603 samples within 2 assays 
## Active assay: RNA (21855 features)
##  1 other assay present: HTO

Preliminary pre-processing of RNA data

This section of the report provides first insights into your RNA dataset based on a preliminary pre-processing of the RNA data using the standard scRNA-seq workflow.

Visualisation of demultiplexed RNA data

We use a UMAP to visualise and explore a dataset. The goal is to place similar cells together in 2D space, and learn about the biology underlying the data. Cells are color-coded according to the assigned sample-of-origin.

Take care not to mis-read a UMAP:

  • Parameters influence the plot (we use defaults here)
  • Cluster sizes relative to each other mean nothing, since the method has a local notion of distance
  • Distances between clusters might not mean anything
  • You may need more than one plot

For a nice read to intuitively understand UMAP, see https://pair-code.github.io/understanding-umap/.

Write out demultiplexed data

Finally, demultiplexed RNA data are written back to file.

## [1] "testDatasets/10x_pbmc_hto_GSE108313/results/demultiplexed_samples/htoH"
## [2] "testDatasets/10x_pbmc_hto_GSE108313/results/demultiplexed_samples/htoG"
## [3] "testDatasets/10x_pbmc_hto_GSE108313/results/demultiplexed_samples/htoF"
## [4] "testDatasets/10x_pbmc_hto_GSE108313/results/demultiplexed_samples/htoE"
## [5] "testDatasets/10x_pbmc_hto_GSE108313/results/demultiplexed_samples/htoD"
## [6] "testDatasets/10x_pbmc_hto_GSE108313/results/demultiplexed_samples/htoC"
## [7] "testDatasets/10x_pbmc_hto_GSE108313/results/demultiplexed_samples/htoB"
## [8] "testDatasets/10x_pbmc_hto_GSE108313/results/demultiplexed_samples/htoA"